﻿using System;
using System.Configuration;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Collections.Generic;

namespace Shuba.Web.ws
{
    public class DBConn
    {
        static Shuba.Framework.Encryption Encryption = new Shuba.Framework.Encryption();
        static string DBServer = ConfigurationManager.AppSettings["db.server"];
        static string DBName = ConfigurationManager.AppSettings["db.name"];
        static string DBUser = ConfigurationManager.AppSettings["db.user"];
        static string DBPass = Encryption.Decrypt(ConfigurationManager.AppSettings["db.pwd"]);
        static string cn = String.Format("Data Source = {0}; Initial Catalog = {1}; User Id = {2}; Password = {3}; Connect Timeout = 30; Min Pool Size = 5", DBServer, DBName, DBUser, DBPass);
        static DbProviderFactory provider = DbProviderFactories.GetFactory("System.Data.SqlClient");

        public static Database CreateDatabase()
        {
            return new GenericDatabase(cn, provider);
        }
    }
}